<template>
  <Tabs>
    <TabPane label="微信参数设置" name="微信参数设置">
      <Card>
        <template #title>
          <strong>微信参数设置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用微信支付：</strong>
          </Col>
          <Col span="12">
          <Select v-model="wechatParams.enable" placeholder="请选择是否启用微信支付" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          <Button class="disableBtn" type="primary" @click="onWechatDisable">{{ wechatParams.disable ? '启用' : '禁用'
          }}</Button>
          </Col>
        </Row>
        <div v-show="wechatParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>微信绑定模式：</strong>
            </Col>
            <Col span="12">
            <Select v-model="wechatParams.bindModel" placeholder="请选择微信绑定模式" class="form">
              <Option v-for="item in wechatPayModels" :value="item.id" :key="item.id">{{ item.name }}</Option>
            </Select>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>微信折扣：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="默认100不打折" placement="right-start">
              <InputNumber class="form" :max="100" :min="1" v-model="wechatParams.discount"
                :formatter="value => `${value}%`" />
            </Tooltip>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>微信商户号：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="请填写小微商户号" placement="right-start">
              <Input v-model="wechatParams.merchantID" placeholder="请输入微信商户号" class="form" />
            </Tooltip>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>姓名：</strong>
            </Col>
            <Col span="12">
            <Input v-model="wechatParams.name" placeholder="请输入姓名" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>银行账户：</strong>
            </Col>
            <Col span="12">
            <Input v-model="wechatParams.bankAccount" placeholder="请输入银行账户" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>客服电话：</strong>
            </Col>
            <Col span="12">
            <Input v-model="wechatParams.servicePhone" placeholder="请输入客服电话" class="form" />
            </Col>
          </Row>
        </div>
        <div class="band">
          <strong class="bandTitle">微信个人收款,收取6‰手续费。请慎重填写并认真核对，提交后不支持修改！</strong>
          <Button :disabled="wechatParams.disable" class="bandBtn" type="primary" @click="onWechatBind">绑定</Button>
        </div>
      </Card>
    </TabPane>
    <TabPane label="支付宝参数设置" name="支付宝参数设置">
      <Card>
        <template #title>
          <strong>支付宝参数设置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用支付宝：</strong>
          </Col>
          <Col span="12">
          <Select v-model="alipayParams.enable" placeholder="请选择是否启用支付宝" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
        </Row>
        <div v-show="alipayParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝绑定模式：</strong>
            </Col>
            <Col span="12">
            <Select v-model="alipayParams.bindModel" placeholder="请选择支付宝绑定模式" class="form">
              <Option v-for="item in alipayPayModels" :value="item.id" :key="item.id">{{ item.name }}</Option>
            </Select>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝折扣：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="默认100不打折" placement="right-start">
              <InputNumber class="form" :max="100" :min="1" v-model="alipayParams.discount"
                :formatter="value => `${value}%`" />
            </Tooltip>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝参数设置：</strong>
            </Col>
            <Col span="12">
            <Button type="primary" @click="onAlipayScan">点击此处扫码设置支付宝参数</Button>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝账户名称：</strong>
            </Col>
            <Col span="12">
            <Input v-model="alipayParams.accountName" placeholder="请输入支付宝账户名称" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝商户号：</strong>
            </Col>
            <Col span="12">
            <Input v-model="alipayParams.merchantID" placeholder="请输入支付宝商户号" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>支付宝账户：</strong>
            </Col>
            <Col span="12">
            <Input v-model="alipayParams.account" placeholder="请输入支付宝账户" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>客服电话：</strong>
            </Col>
            <Col span="12">
            <Input v-model="alipayParams.servicePhone" placeholder="请输入客服电话" class="form" />
            </Col>
          </Row>
        </div>
        <div class="band">
          <strong class="bandTitle">直付通收款，收取6‰手续费，请慎重填写并认真核对，提交后不支持修改!</strong>
          <Button class="bandBtn" type="primary" @click="onAlipayBind">绑定</Button>
        </div>
      </Card>
      <Modal mask :closable="false" cancel-text=" " ok-text="扫描完成" v-model="alipayParams.visible" title="扫码设置支付宝参数">
        <p class="bandTitle">链接地址：http://www.tcnvmms.com/zftjoin/zftbind?sstid=59820</p>
        <img class="qrcode-img" src="https://www.liantu.com/images/2013/liantu.png">
        <p class="bandTitle">用申请成功的支付宝账号扫描上方二维码，扫描完成后再点击页面下方“绑定”按钮完成操作！</p>
      </Modal>
    </TabPane>
    <TabPane label="刷脸参数设置" name="刷脸参数设置">
      <Card>
        <template #title>
          <strong>刷脸参数设置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用支付宝刷脸参数配置：</strong>
          </Col>
          <Col span="12">
          <Select v-model="faceSwipParams.enable" placeholder="请选择是否启用支付宝刷脸参数配置" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
        </Row>
        <div v-show="faceSwipParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>刷脸模式：</strong>
            </Col>
            <Col span="12">
            <Select v-model="faceSwipParams.swipModel" placeholder="请选择刷脸模式" class="form">
              <Option v-for="item in faceSwipPayModels" :value="item.id" :key="item.id">{{ item.name }}
              </Option>
            </Select>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>Pid：</strong>
            </Col>
            <Col span="12">
            <Input v-model="faceSwipParams.pid" placeholder="请输入Pid" class="form" />
            </Col>
          </Row>
        </div>
        <div class="band">
          <Button class="bandBtn" type="primary" @click="onFaceSwipSave">绑定</Button>
        </div>
      </Card>
    </TabPane>
    <TabPane label="京东参数设置" name="京东参数设置">
      <Card>
        <template #title>
          <strong>京东参数设置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用京东支付：</strong>
          </Col>
          <Col span="12">
          <Select v-model="jdParams.enable" placeholder="请选择是否是否启用京东支付" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
        </Row>
        <div v-show="jdParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>京东支付模式：</strong>
            </Col>
            <Col span="12">
            <Select v-model="jdParams.payModel" placeholder="请选择京东支付模式" class="form">
              <Option v-for="item in jdPayModels" :value="item.id" :key="item.id">{{ item.name }}</Option>
            </Select>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>京东折扣：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="默认100不打折" placement="right-start">
              <InputNumber class="form" :max="100" :min="1" v-model="jdParams.discount"
                :formatter="value => `${value}%`" />
            </Tooltip>
            </Col>
          </Row>
          <div v-show="jdParams.payModel === 4">
            <Row class="row">
              <Col span="12" class="title">
              <strong>结算银行名称：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.bankName" placeholder="请输入结算银行名称" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>个人银行结算姓名：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.name" placeholder="请输入个人银行结算姓名" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>结算卡号：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.cardNum" placeholder="请输入结算卡号" class="form" />
              </Col>
            </Row>
          </div>
          <div v-show="jdParams.payModel === 5">
            <Row class="row">
              <Col span="12" class="title">
              <strong>京东商户号：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.merchantID" placeholder="请输入京东商户号" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>京东秘钥：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.secretKey" placeholder="请输入京东秘钥" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>京东私密：</strong>
              </Col>
              <Col span="12">
              <Input v-model="jdParams.privateKey" placeholder="请输入京东私密" class="form" />
              </Col>
            </Row>
          </div>
        </div>
        <div class="band">
          <strong class="bandTitle">京东个人收款，收取6‰手续费;结算到个人银行卡固定收每笔1.5元手续费。请慎重填写并认真核对，提交后不支持修改！</strong>
          <Button class="bandBtn" type="primary" @click="onJDBind">绑定</Button>
        </div>
      </Card>
    </TabPane>
    <TabPane label="翼支付参数设置" name="翼支付参数设置">
      <Card>
        <template #title>
          <strong>翼支付参数设置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用翼支付：</strong>
          </Col>
          <Col span="12">
          <Select v-model="bestpayParams.enable" placeholder="请选择是否是否启用翼支付" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
        </Row>
        <div v-show="bestpayParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>翼支付模式：</strong>
            </Col>
            <Col span="12">
            <Select v-model="bestpayParams.payModel" placeholder="请选择翼支付模式" class="form">
              <Option v-for="item in bestpayPayModels" :value="item.id" :key="item.id">{{ item.name }}</Option>
            </Select>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>翼支付折扣：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="默认100不打折" placement="right-start">
              <InputNumber class="form" :max="100" :min="1" v-model="bestpayParams.discount"
                :formatter="value => `${value}%`" />
            </Tooltip>
            </Col>
          </Row>
          <div v-show="bestpayParams.payModel === 7">
            <Row class="row">
              <Col span="12" class="title">
              <strong>翼支付商户号：</strong>
              </Col>
              <Col span="12">
              <Input v-model="bestpayParams.merchantID" placeholder="请输入翼支付商户号" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>翼支付交易key：</strong>
              </Col>
              <Col span="12">
              <Input v-model="bestpayParams.tradeKey" placeholder="请输入翼支付交易key" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>翼支付数据key：</strong>
              </Col>
              <Col span="12">
              <Input v-model="bestpayParams.dataKey" placeholder="请输入翼支付数据key" class="form" />
              </Col>
            </Row>
          </div>
          <div v-show="bestpayParams.payModel === 8">
            <Row class="row">
              <Col span="12" class="title">
              <strong>翼支付分帐商户号：</strong>
              </Col>
              <Col span="12">
              <Input v-model="bestpayParams.subledgerMerchantID" placeholder="翼支付分帐商户号" class="form" />
              </Col>
            </Row>
          </div>
          <div v-show="bestpayParams.payModel === 9">
            <Row class="row">
              <Col span="12" class="title">
              <strong>翼支付商户号：</strong>
              </Col>
              <Col span="12">
              <Input v-model="bestpayParams.merchantID" placeholder="请输入翼支付商户号" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>用户证书物理路径：</strong>
              </Col>
              <Col span="12">
              <Upload action="
http://admin.vmcloud.ink/api/personalsetting/uPicture" :on-success="onUserCertUpload"
                :on-remove="onUserCertRemove">
                <Button icon="ios-cloud-upload-outline">选择文件</Button>
              </Upload>
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>用户证书密码：</strong>
              </Col>
              <Col span="12">
              <Input type="password" v-model="bestpayParams.userCertificatePwd" placeholder="请输入用户证书密码" class="form" />
              </Col>
            </Row>
            <Row class="row">
              <Col span="12" class="title">
              <strong>服务器证书物理路径：</strong>
              </Col>
              <Col span="12">
              <Upload action="http://admin.vmcloud.ink/api/personalsetting/uPicture" :on-success="onServerCertUpload"
                :on-remove="onServerCertRemove">
                <Button icon="ios-cloud-upload-outline">选择文件</Button>
              </Upload>
              </Col>
            </Row>
          </div>
        </div>
        <div class="band">
          <strong class="bandTitle">翼支付个人收款,收取6‰手续费；请慎重填写并认真核对，提交后不支持修改！</strong>
          <Button class="bandBtn" type="primary" @click="onBestPayBind">绑定</Button>
        </div>
      </Card>
    </TabPane>
    <TabPane label="银商参数配置" name="银商参数配置">
      <Card>
        <template #title>
          <strong>银商参数配置</strong>
        </template>
        <Row class="row">
          <Col span="12" class="title">
          <strong>是否启用银商支付：</strong>
          </Col>
          <Col span="12">
          <Select v-model="silverParams.enable" placeholder="请选择是否启用银商支付" class="form">
            <Option v-for="item in whetherList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
          </Col>
        </Row>
        <div v-show="silverParams.enable === '是'">
          <Row class="row">
            <Col span="12" class="title">
            <strong>银商折扣：</strong>
            </Col>
            <Col span="12">
            <Tooltip content="默认100不打折" placement="right-start">
              <InputNumber class="form" :max="100" :min="1" v-model="silverParams.discount"
                :formatter="value => `${value}%`" />
            </Tooltip>
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>银联商户号：</strong>
            </Col>
            <Col span="12">
            <Input v-model="silverParams.merchantID" placeholder="请输入银联商户号" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>银联终端号：</strong>
            </Col>
            <Col span="12">
            <Input v-model="silverParams.terminalID" placeholder="请输入银联终端号" class="form" />
            </Col>
          </Row>
          <Row class="row">
            <Col span="12" class="title">
            <strong>数字货币：</strong>
            </Col>
            <Col span="12">
            <Tooltip :max-width="200" content="开启前请确保已开通数字货币，否则消费者无法使用数字货币支付，开通步骤请在“云数加盟”联系云数客服进行开通"
              placement="right-start">
              <Checkbox v-model="silverParams.enableCurrency">是否开启数字货币</Checkbox>
            </Tooltip>
            </Col>
          </Row>
        </div>
        <div class="band">
          <strong class="bandTitle">银联商务收款，收取6‰手续费；请慎重填写并认真核对，提交后不支持修改！</strong>
          <Button class="bandBtn" type="primary" @click="onSilverBind">绑定</Button>
        </div>
      </Card>
    </TabPane>
  </Tabs>
</template>

<script>
import {
  whetherList,
  jdPayModelList,
  bestPayModelList,
} from '@/mock/data/option-data.js'
import rcRequest from 'rc-request'
import jsCookie from 'js-cookie'

export default {
  name: 'agent-trademark-page',
  data() {
    return {
      // 微信参数设置
      wechatPayModels: [],
      wechatParams: {
        id: 0,
        enable: '是', // 是否启用
        disable: false, // 是否禁用
        bindModel: '云商服务器', // 绑定模式
        discount: 100, // 折扣
        merchantID: '1626599950', // 微信商户号
        name: '林荣', // 姓名
        bankAccount: '工商银行 6222***********3820', // 银行账号
        servicePhone: '18929455118', // 客服电话
      },

      // 支付宝参数设置
      alipayPayModels: [],
      alipayParams: {
        id: 0,
        enable: '是', // 是否启用
        bindModel: '直付通', // 绑定模式
        discount: 100, // 折扣
        accountName: '林荣', // 账户名称
        merchantID: '2088610367330373', // 商户ID
        account: '18929455118', // 账号
        servicePhone: '18929455118', // 客服电话
        visible: false, // 扫码设置支付宝参数
      },

      // 刷脸参数设置
      faceSwipPayModels: [],
      faceSwipParams: {
        id: 0,
        enable: '是', // 是否启用
        swipModel: '个人刷脸模式', // 刷脸模式
        pid: '2088442364921821',
      },

      // 京东参数设置
      jdPayModels: [],
      jdParams: {
        id: 0,
        enable: '是', // 是否启用
        payModel: '默认设置', // 支付模式
        discount: 100, // 折扣
        bankName: '', // 结算银行名称
        name: '', // 个人银行结算姓名
        cardNum: '', // 结算卡号
        merchantID: '', // 商户号
        secretKey: '', // 秘钥
        privateKey: '', // 私钥
      },

      // 翼支付参数设置
      bestpayPayModels: [],
      bestpayParams: {
        id: 0,
        enable: '是', // 是否启用
        payModel: '默认设置', // 支付模式
        discount: 100, // 折扣
        merchantID: '', // 商户号
        tradeKey: '', // 交易key
        dataKey: '', // 数据key
        subledgerMerchantID: '', // 分账商户号
        userCertificatePath: [], // 用户证书物理路径
        userCertificatePwd: '', // 用户证书密码
        serverCertificatePath: [], // 服务器证书物理路径
      },

      // 银商参数设置
      silverPayModels: [],
      silverParams: {
        id: 0,
        enable: '是', // 是否启用
        discount: 100, // 折扣
        merchantID: '', // 商户号
        terminalID: '', // 终端号
        enableCurrency: true, // 是否开通数字货币
      },

      // 选择器数据
      whetherList,
      jdPayModelList,
      bestPayModelList,
    };
  },
  methods: {
    // 微信参数设置 -> 是否禁用
    async onWechatDisable() {
      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 1,
          pay_argument_id: this.wechatParams.id,
          is_forbidden: this.wechatParams.disable ? 0 : 1,
          is_use: this.wechatParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.wechatParams.bindModel,
          discount: this.wechatParams.discount,
          merchant_number: this.wechatParams.merchantID,
          compellation: this.wechatParams.name,
          bank_number: this.wechatParams.bankAccount,
          phone: this.wechatParams.servicePhone,
        },
      })
      this.wechatParams.disable = !this.wechatParams.disable;
      this.$Message.info('微信支付参数修改成功！');
    },
    // 微信参数设置 -> 绑定
    async onWechatBind() {
      if (this.wechatParams.merchantID.length === 0) {
        this.$Message.error('微信商户号不能为空');
        return;
      }
      if (this.wechatParams.name.length === 0) {
        this.$Message.error('姓名不能为空');
        return;
      }
      if (this.wechatParams.bankAccount.length === 0) {
        this.$Message.error('银行账号不能为空');
        return;
      }
      if (this.wechatParams.servicePhone.length === 0) {
        this.$Message.error('客服电话不能为空');
        return;
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 1,
          pay_argument_id: this.wechatParams.id,
          is_forbidden: this.wechatParams.disable ? 1 : 0,
          is_use: this.wechatParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.wechatParams.bindModel,
          discount: this.wechatParams.discount,
          merchant_number: this.wechatParams.merchantID,
          compellation: this.wechatParams.name,
          bank_number: this.wechatParams.bankAccount,
          phone: this.wechatParams.servicePhone,
        },
      })
      
      this.$Message.info('绑定成功！');
    },

    // 支付宝参数设置 -> 扫码
    onAlipayScan() {
      this.alipayParams.visible = true;
    },
    // 支付宝参数设置 -> 绑定
    async onAlipayBind() {
      if (this.alipayParams.accountName.length === 0) {
        this.$Message.error('支付宝账号名称不能为空');
        return;
      }
      if (this.alipayParams.merchantID.length === 0) {
        this.$Message.error('支付宝商户号不能为空');
        return;
      }
      if (this.alipayParams.account.length === 0) {
        this.$Message.error('支付宝账号不能为空');
        return;
      }
      if (this.alipayParams.servicePhone.length === 0) {
        this.$Message.error('客服电话不能为空');
        return;
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 2,
          pay_argument_id: this.alipayParams.id,
          is_forbidden: this.alipayParams.disable ? 1 : 0,
          is_use: this.alipayParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.alipayParams.bindModel,
          discount: this.alipayParams.discount,
          compellation: this.alipayParams.accountName,
          merchant_number: this.alipayParams.merchantID,
          alipay_account: this.alipayParams.account,
          phone: this.alipayParams.servicePhone,
        },
      })

      this.$Message.info('绑定成功！');
    },

    // 刷脸参数设置 -> 绑定
    async onFaceSwipSave() {
      if (this.faceSwipParams.pid.length === 0) {
        this.$Message.error('Pid不能为空');
        return;
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 3,
          pay_argument_id: this.faceSwipParams.id,
          is_forbidden: this.faceSwipParams.disable ? 1 : 0,
          is_use: this.faceSwipParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.faceSwipParams.swipModel,
          pid: this.faceSwipParams.pid,
        },
      })

      this.$Message.info('绑定成功！');
    },

    // 京东参数设置-> 绑定
    async onJDBind() {
      if (this.jdParams.payModel === '默认设置') {
        if (this.jdParams.bankName.length === 0) {
          this.$Message.error('结算银行名称不能为空！');
          return;
        }
        if (this.jdParams.name.length === 0) {
          this.$Message.error('个人银行结算姓名不能为空！');
          return;
        }
        if (this.jdParams.cardNum.length === 0) {
          this.$Message.error('结算卡号不能为空！');
          return;
        }
      }

      if (this.jdParams.payModel === '自定义设置') {
        if (this.jdParams.merchantID.length === 0) {
          this.$Message.error('京东商户号不能为空！');
          return;
        }
        if (this.jdParams.secretKey.length === 0) {
          this.$Message.error('京东秘钥不能为空！');
          return;
        }
        if (this.jdParams.privateKey.length === 0) {
          this.$Message.error('京东私密不能为空！');
          return;
        }
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 4,
          pay_argument_id: this.jdParams.id,
          is_forbidden: this.jdParams.disable ? 1 : 0,
          is_use: this.jdParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.jdParams.payModel,
          discount: this.jdParams.discount,
          bank_name: this.jdParams.bankName,
          compellation: this.jdParams.name,
          bank_number: this.jdParams.cardNum,
          merchant_number: this.jdParams.merchantID,
          secret_key: this.jdParams.secretKey,
          privacy_key: this.jdParams.privateKey,
        },
      })

      this.$Message.info('绑定成功！');
    },

    // 翼支付参数设置 -> 用户证书 -> 上传
    onUserCertUpload({ data }) {
      this.bestpayParams.userCertificatePath = data;
    },
    // 翼支付参数设置 -> 用户证书 -> 移除
    onUserCertRemove() {
      this.bestPayModelList.userCertificatePath = '';
    },
    // 翼支付参数设置 -> 服务器证书 -> 上传
    onServerCertUpload({ data }) {
      this.bestpayParams.serverCertificatePath = data
    },
    // 翼支付参数设置 -> 服务器证书 -> 移除
    onServerCertRemove() {
      this.bestPayModelList.serverCertificatePath = '';
    },
    // 翼支付参数设置 -> 绑定
    async onBestPayBind() {
      if (this.bestpayParams.payModel === '自定义设置') {
        if (this.bestpayParams.merchantID.length === 0) {
          this.$Message.error('翼支付商户号不能为空！');
          return;
        }
        if (this.bestpayParams.tradeKey.length === 0) {
          this.$Message.error('翼支付交易key不能为空！');
          return;
        }
        if (this.bestpayParams.dataKey.length === 0) {
          this.$Message.error('翼支付数据key不能为空！');
          return;
        }
      }

      if (this.bestpayParams.payModel === 'V3个人') {
        if (this.bestpayParams.subledgerMerchantID.length === 0) {
          this.$Message.error('翼支付分帐商户号不能为空！');
          return;
        }
      }

      if (this.bestpayParams.payModel === 'V4企业') {
        if (this.bestpayParams.merchantID.length === 0) {
          this.$Message.error('翼支付商户号不能为空！');
          return;
        }
        if (this.bestpayParams.userCertificatePath.length === 0) {
          this.$Message.error('请上传用户证书！');
          return;
        }
        if (this.bestpayParams.userCertificatePwd.length === 0) {
          this.$Message.error('用户证书密码不能为空！');
          return;
        }
        if (this.bestpayParams.serverCertificatePath.length === 0) {
          this.$Message.error('请上传服务器证书！');
          return;
        }
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 5,
          pay_argument_id: this.bestpayParams.id,
          is_forbidden: this.bestpayParams.disable ? 1 : 0,
          is_use: this.bestpayParams.enable === '否' ? 1 : 0,
          is_digital_currency: 1,
          pay_model_id: this.bestpayParams.payModel,
          discount: this.bestpayParams.discount,
          merchant_number: this.bestpayParams.merchantID,
          trading_key: this.bestpayParams.tradeKey,
          data_key: this.bestpayParams.dataKey,
          points_merchant_number: this.bestpayParams.subledgerMerchantID,
          user_certificate: this.bestpayParams.userCertificatePath,
          user_certificate_password: this.bestpayParams.userCertificatePwd,
          server_certificate: this.bestpayParams.serverCertificatePath,
        },
      })

      this.$Message.info('绑定成功！');
      return;
    },

    // 银商参数设置 -> 绑定
    async onSilverBind() {
      if (this.silverParams.merchantID.length === 0) {
        this.$Message.error('银联商户号不能为空！');
        return;
      }

      if (this.silverParams.terminalID.length === 0) {
        this.$Message.error('银联终端号不能为空！');
        return;
      }

      await rcRequest({
        method: 'post',
        url: '/payargument/update_pay_argument_info',
        data: {
          type: 6,
          pay_argument_id: this.silverParams.id,
          is_forbidden: this.silverParams.disable ? 1 : 0,
          is_use: this.silverParams.enable === '否' ? 1 : 0,
          is_digital_currency: this.silverParams.enableCurrency ? 0 : 1,
          pay_model_id: 10,
          discount: this.silverParams.discount,
          merchant_number: this.silverParams.merchantID,
          terminal_number: this.silverParams.terminalID,
        },
      })

      this.$Message.info('绑定成功！');
      return;
    },

    // 查询支付模式
    async getPayArgumentData() {
      // 微信参数设置
      const { data: { data: wechatPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 1,
        },
      })
      this.wechatPayModels = wechatPayModels;
      // 支付宝参数设置
      const { data: { data: alipayPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 2,
        },
      })
      this.alipayPayModels = alipayPayModels;
      // 刷脸参数设置
      const { data: { data: faceSwipPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 3,
        },
      })
      this.faceSwipPayModels = faceSwipPayModels;
      // 京东参数设置
      const { data: { data: jdPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 4,
        },
      })
      this.jdPayModels = jdPayModels;
      // 翼支付参数设置
      const { data: { data: bestpayPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 5,
        },
      })
      this.bestpayPayModels = bestpayPayModels;
      // 银商参数设置
      const { data: { data: silverPayModels } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_model_info',
        data: {
          type: 6,
        },
      })
      this.silverPayModels = silverPayModels;
    },

    // 查询用户支付参数
    async getUserPayArgument() {
      // 微信参数设置
      const { data: { data: [wechatParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 1,
        }
      })
      this.wechatParams.id = wechatParams.id;
      this.wechatParams.enable = wechatParams.is_use ? '否' : '是';
      this.wechatParams.disable = !!wechatParams.is_forbidden;
      this.wechatParams.bindModel = wechatParams.pay_model_id;
      this.wechatParams.discount = wechatParams.discount;
      this.wechatParams.merchantID = wechatParams.merchant_number;
      this.wechatParams.name = wechatParams.compellation;
      this.wechatParams.bankAccount = wechatParams.bank_number;
      this.wechatParams.servicePhone = wechatParams.phone;

      // 支付宝参数设置
      const { data: { data: [alipayParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 2,
        }
      })
      this.alipayParams.id = alipayParams.id;
      this.alipayParams.enable = alipayParams.is_use ? '否' : '是';
      this.alipayParams.bindModel = alipayParams.pay_model_id;
      this.alipayParams.discount = alipayParams.discount;
      this.alipayParams.accountName = alipayParams.compellation;
      this.alipayParams.merchantID = alipayParams.merchant_number;
      this.alipayParams.account = alipayParams.alipay_account;
      this.alipayParams.servicePhone = alipayParams.phone;

      // 刷脸参数设置
      const { data: { data: [faceSwipParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 3,
        }
      })
      this.faceSwipParams.id = faceSwipParams.id;
      this.faceSwipParams.enable = faceSwipParams.is_use ? '否' : '是';
      this.faceSwipParams.swipModel = faceSwipParams.pay_model_id;
      this.faceSwipParams.pid = faceSwipParams.pid;

      // 京东参数设置
      const { data: { data: [jdParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 4,
        }
      })
      this.jdParams.id = jdParams.id;
      this.jdParams.enable = jdParams.is_use ? '否' : '是';
      this.jdParams.payModel = jdParams.pay_model_id;
      this.jdParams.discount = jdParams.discount;
      this.jdParams.bankName = jdParams.bank_name;
      this.jdParams.name = jdParams.compellation;
      this.jdParams.cardNum = jdParams.bank_number;
      this.jdParams.merchantID = jdParams.merchant_number;
      this.jdParams.secretKey = jdParams.secret_key;
      this.jdParams.privateKey = jdParams.privacy_key;

      // 翼支付参数设置
      const { data: { data: [bestpayParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 5,
        }
      })
      this.bestpayParams.id = bestpayParams.id;
      this.bestpayParams.enable = bestpayParams.is_use ? '否' : '是';
      this.bestpayParams.payModel = bestpayParams.pay_model_id;
      this.bestpayParams.discount = bestpayParams.discount;
      this.bestpayParams.merchantID = bestpayParams.merchant_number;
      this.bestpayParams.tradeKey = bestpayParams.trading_key;
      this.bestpayParams.dataKey = bestpayParams.data_key;
      this.bestpayParams.subledgerMerchantID = bestpayParams.points_merchant_number;
      this.bestpayParams.userCertificatePath = bestpayParams.user_certificate;
      this.bestpayParams.userCertificatePwd = bestpayParams.user_certificate_password;
      this.bestpayParams.serverCertificatePath = bestpayParams.server_certificate;

      // 银商参数设置
      const { data: { data: [silverParams] } } = await rcRequest({
        method: 'post',
        url: '/payargument/select_pay_argument_info',
        data: {
          type: 6,
        }
      })
      this.silverParams.id = silverParams.id;
      this.silverParams.enable = silverParams.is_use ? '否' : '是';
      this.silverParams.discount = silverParams.discount;
      this.silverParams.merchantID = silverParams.merchant_number || '';
      this.silverParams.terminalID = silverParams.terminal_number || '';
      this.silverParams.enableCurrency = !silverParams.is_digital_currency;
    },
  },
  mounted() {
    this.getPayArgumentData()
    this.getUserPayArgument()
  },
}
</script>

<style scoped>
.row {
  margin-top: 20px;
  display: flex;
  align-items: center;
}

.title {
  display: flex;
  justify-content: flex-end;
  padding-right: 20px;
}

.form {
  width: 300px;
}

.disableBtn {
  margin-left: 7px;
}

.band {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin-top: 30px;
}

.bandTitle {
  color: red;
  font-size: 15px;
}

.bandBtn {
  margin-top: 10px;
  width: 100px;
}

.qrcode-img {
  width: 240px;
  height: 240px;
  margin-top: 15px;
  margin-bottom: 15px;
}
</style>